<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">订单表</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">用户：</text></view>
                  <input  placeholder="请输入用户" v-model="model.userId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">用户手机号：</text></view>
                  <input  placeholder="请输入用户手机号" v-model="model.userPhone"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">订单号：</text></view>
                  <input  placeholder="请输入订单号" v-model="model.orderNo"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">商户号：</text></view>
                  <input  placeholder="请输入商户号" v-model="model.mchno"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">应用id：</text></view>
                  <input  placeholder="请输入应用id" v-model="model.appId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">支付方式：</text></view>
                  <input  placeholder="请输入支付方式" v-model="model.wayCode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">支付金额(分)：</text></view>
                  <input type="number" placeholder="请输入支付金额(分)" v-model="model.amount"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">客户端ip：</text></view>
                  <input  placeholder="请输入客户端ip" v-model="model.clientIp"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">订单标题：</text></view>
                  <input  placeholder="请输入订单标题" v-model="model.subject"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">订单描述：</text></view>
                  <input  placeholder="请输入订单描述" v-model="model.body"/>
                </view>
              </view>
              <my-date label="失效时间：" v-model="model.expiredTime" placeholder="请输入失效时间"></my-date>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">渠道参数：</text></view>
                  <input  placeholder="请输入渠道参数" v-model="model.channelExtra"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">分账模式：</text></view>
                  <input  placeholder="请输入分账模式" v-model="model.divisionMode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">扩展参数：</text></view>
                  <input  placeholder="请输入扩展参数" v-model="model.extParam"/>
                </view>
              </view>
              <my-date label="请求时间：" v-model="model.reqTime" placeholder="请输入请求时间"></my-date>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">签名：</text></view>
                  <input  placeholder="请输入签名" v-model="model.sign"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">签名类型：</text></view>
                  <input  placeholder="请输入签名类型" v-model="model.signType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">异步通知地址：</text></view>
                  <input  placeholder="请输入异步通知地址" v-model="model.notifyUrl"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">跳转通知地址：</text></view>
                  <input  placeholder="请输入跳转通知地址" v-model="model.returnUrl"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">订单状态：</text></view>
                  <input  placeholder="请输入订单状态" v-model="model.orderState"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">支付数据类型：</text></view>
                  <input  placeholder="请输入支付数据类型" v-model="model.payDataType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">发起支付数据：</text></view>
                  <input  placeholder="请输入发起支付数据" v-model="model.payData"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">渠道错误码：</text></view>
                  <input  placeholder="请输入渠道错误码" v-model="model.errCode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">渠道错误描述：</text></view>
                  <input  placeholder="请输入渠道错误描述" v-model="model.errMsg"/>
                </view>
              </view>
              <my-date label="支付成功时间：" v-model="model.successTime" placeholder="请输入支付成功时间"></my-date>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">业务类型：</text></view>
                  <input  placeholder="请输入业务类型" v-model="model.bizType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">业务数据：</text></view>
                  <input  placeholder="请输入业务数据" v-model="model.bizDate"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "WlhyOrderForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/order/wlhyOrder/queryById",
                  add: "/order/wlhyOrder/add",
                  edit: "/order/wlhyOrder/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
